package org.activequant.core.domainmodel.marketscanner;

import java.io.Serializable;

import org.activequant.core.types.TimeStamp;
/**
 * Market scan entity, base class for marketScan indications<br>
 * An abstract class (with an abstract <code>clone()</code> method). Holds the following associated variables:
 * <ul>
 * <li>id(Long)</li>
 * <li>scanCriteria(ScanCriteria)</li>
 * <li>timeStamp(TimeStamp)</li>
 * </ul>
 * @author Dimitar
 *
 * @param <T>
 */
public abstract class ScanDataEntity<T extends ScanDataEntity<T>> implements Comparable<T>, Serializable {
	/**
	 * public static final int NOT_SET = -1;
	 */
	public static final int NOT_SET = -1;
	
	/**
	 * private Long id = null;<br/>
	 * id of this market entity.
	 */
	private Long id = null;

	/**
	 * private ScanCriteria scanCriteria;<br/>
	 * the specification for this market entity.
	 */
	private ScanCriteria scanCriteria;
	
	/**
	 * private TimeStamp timeStamp = new TimeStamp();<br/>
	 * the date of this market entity. 
	 */
	private TimeStamp timeStamp = new TimeStamp();
	
	public abstract T clone();
	/**
	 * empty constructor
	 */
	public ScanDataEntity() {
	}
	/**
	 * constructs a MarketDataEntity using the given date(TimeStamp) to set its associated timeStamp(TimeStamp)
	 * @param date
	 */
	public ScanDataEntity(TimeStamp date) {
		this.timeStamp = date;
	}
	/**
	 * constructs a MarketDataEntity using the given scanCriteria(ScanCriteria) to set its associated scanCriteria(ScanCriteria)
	 * @param scanCriteria
	 */
	public ScanDataEntity(ScanCriteria scanCriteria) {
		this.scanCriteria = scanCriteria;
	}
	/**
	 * constructs a MarketDataEntity using the given scanCriteria(ScanCriteria) and date(TimeStamp) to set its associated 
	 * scanCriteria(ScanCriteria) and timeStamp(TimeStamp)
	 * @param scanCriteria
	 * @param date
	 */
	public ScanDataEntity(ScanCriteria scanCriteria, TimeStamp date) {
		this.scanCriteria = scanCriteria;
		this.timeStamp = date;
	}
	
	/**
	 * returns the associated scanCriteria(ScanCriteria)
	 * @return
	 */
	public ScanCriteria getScanCriteria() {
		return scanCriteria;
	}
	/**
	 * sets the associated scanCriteria(ScanCriteria) with the given scanCriteria(ScanCriteria)
	 * @param instrumentSpecification
	 */
	public void setScanCriteria(ScanCriteria scanCriteria) {
		this.scanCriteria = scanCriteria;
	}

	/**
	 * TimeStamp when this event hits the market.
	 * <em>IMPORTANT</em> for Candles it corresponds to the <em>close</em>
	 * time, so that Candle accumulates events up to the time stamp.<br/>
	 * returns the associated timeStamp(TimeStamp)
	 * @return event time stamp.
	 */
	public TimeStamp getTimeStamp() {
		return timeStamp;
	}

	/**
	 * Sets event time stamp.<br/>
	 * sets the associated timeStamp(TimeStamp) with the given stamp(TimeStamp)
	 * @param stamp time stamp.
	 */
	public void setTimeStamp(TimeStamp stamp) {
		this.timeStamp = stamp;
	} 
	/**
	 * returns whether the associated id(Long) is not <code>null</code>
	 * @return
	 */
	public boolean hasId() {
		return id != null;
	}
	/**
	 * returns the associated id(Long)
	 * @return
	 */
	public Long getId() {
		return id;
	}
	/**
	 * sets the associated id(Long) with the given id(Long)
	 * @param id
	 */
	public void setId(Long id) {
		this.id = id;
	}
}